﻿//-----------------------------------------------------------------
//
// @(#)$Id: M_UpdatePassWord.aspx.cs,v 1.0 2013/12/16 9:57:00 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/16 9:57:00 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using ebay.Dal.CenterDB_SystemTableAdapters;
using ebay.Utility;

public partial class M_UpdatePassWord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnComplete_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        string userId = Session["UserId"].ToString();
        
        T_UsersTableAdapter userAdapter = new T_UsersTableAdapter();
        DataTable t = userAdapter.GetUserByUserId(userId);
        if (t.Rows.Count > 0)
        {
            string opwd = t.Rows[0]["PassWord"].ToString();
            if (EncryptC.Md532(txtOrignalPassWord.Text.Trim()) == opwd)
            {
                int val = userAdapter.UpdatePass(EncryptC.Md532(txtNewPassWord.Text.Trim()), userId, DateTime.Now, userId);
                if (val > 0)
                {
                    WebUtility.ShowMsg("密码修改成功", this);
                }
            }
            else
            {
                WebUtility.ShowMsg("原密码输入错误,请重新输入", this);            
            }
        }
        else
        {
            WebUtility.ShowMsg("当前用户可能被删除,请与系统管理员联系", this);
        
        }
    }
}
